package com.yjhb.android.sbz.mvp.hall;

import com.yjhb.android.sbz.entity.TaskInfo;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2020/12/2 14:54
 */
public class HallTaskListPresenter extends ConventionPresenter<HallTaskListView> {
    private final String TAG = "HallPresenter";

    public HallTaskListPresenter(HallTaskListView hallTaskListView) {
        super(hallTaskListView);
    }

    @Override
    protected void onDestroy() {

    }


    /**
     *
     * @param sortBy
     * @param type
     * @param categoryId
     * @param size
     * @param current
     */
    public void loadHallList(int sortBy ,Integer type, Integer categoryId, int size, final int current) {
        HttpTool.request(model.hallTaskList(sortBy,type,categoryId,null,size,current), new HttpObserver<List<TaskInfo>>() {
            @Override
            public void onResult(List<TaskInfo> data) {
                if (view != null) {
                    if (current == 1)
                        view.onListData(data, true);
                    else
                        view.onListData(data, false);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

}
